<template>
	<view class="container">
		<view class="jifen">
			<view :style="data.type == 2 ? 'color: #F94441;' : ''">{{ data.after_integral }}</view>
			<view><text>{{ data.type == 1 ? '获取' : '扣除' }}</text>积分成功</view>
		</view>
		<!-- 积分详情 -->
		<view class="detail">
			<view class="info">
				<view>{{ data.type == 1 ? '获取积分' : '扣除积分'}}</view>
				<view class="info_type" :style="data.type == 2 ? 'color: #F94441;' : ''">{{ data.integral }}</view>
			</view>
			<view class="info">
				<view>获取时间</view>
				<view class="info_type" style="color: #999999;">{{ timeStr(data.created_at) }}</view>
			</view>
			<view class="info">
				<view>获取订单</view>
				<view class="info_type" @click="goOrder">查看订单详情</view>
			</view>
			<view class="order" v-for="(item, index) in data.order_goods">
				<view class="goodsName">{{ item.goods_name }}</view>
				<view class="goodsMsg">
					<view>￥<text>{{ item.goods_price }}</text></view>
					<view>x{{ item.buy_num }}</view>
				</view>
			</view>
			<view class="info">
				<view>订单号:</view>
				<view class="info_type" style="color: #999999;">13246598788799</view>
			</view>
			<view class="info">
				<view>下单号:</view>
				<view class="info_type" style="color: #999999;">13246598788799</view>
			</view>
		</view>
		<!-- 疑问 -->
		<view class="question">对此订单有疑惑？</view>
	</view>
</template>

<script>
	export default{
		data() {
			return{
				data: [],
			}
		},
		onLoad(option) {
			this.data = JSON.parse(option.item)
		},
		methods: {
			// 转化时间戳
			timeStr(str) {
				let timeStr = ''
				let timer = new Date(str)
				let year = timer.getFullYear()
				let month = timer.getMonth() + 1 < 10 ? '0' + timer.getMonth() + 1 : timer.getMonth() + 1
				let day = timer.getDate() < 10 ? '0' + timer.getDate() : timer.getDate()
				// let hour = timer.getHours() < 10 ? '0' + timer.getHours() : timer.getHours()
				// let mins = timer.getMinutes() < 10 ? '0' + timer.getMinutes() : timer.getMinutes()
				timeStr = year + '-' + month +  '-' + day
				 // + ' ' +  hour + ':' +  mins
				// console.log(timeStr)
				return timeStr
			},
			//  跳转订单详情
			goOrder() {
				uni.navigateTo({
					url: '/order/orderDetail/index?order_id=' + this.data.form_order_id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.jifen{
		height: 174rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
		text-align: center;
		margin-top: 45rpx;
		&>view:nth-child(1){
			margin-top: 21rpx;
			font-size: 80rpx;
			font-family: zihun64hao-mengquruantangti;
			font-weight: 400;
			color: #3FC4A7;
		}
	}
	.detail{
		overflow: hidden;
		margin: 30rpx 60rpx;
		// height: 582rpx;
		padding: 0 40rpx 40rpx;
		box-sizing: border-box;
		background: #FFFFFF;
		box-shadow: 0px 11rpx 35rpx 0px rgba(144, 144, 144, 0.72);
		border-radius: 20rpx;
		.info{
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
			margin-top: 45rpx;
			.info_type{
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #3EC4A7;
			}
		}
		.order{
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			margin-top: 45rpx;
			.goodsName{
				width: 391rpx;
				height: 80rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #999999;
			}
			.goodsMsg{
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: flex-end;
				&>view:nth-child(1){
					font-size: 22rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					color: #F55519;
					&>text{
						font-size: 30rpx;
					}
				}
				&>view:nth-child(2){
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
			}
		}
	}
	.question{
		margin-top: 100rpx;
		text-align: center;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
	}
</style>
